package com.hanamaki.operator.scanner;

import java.util.Scanner;

public class Scanner3 {

    public static void main(String[] args) {

        /*我们可以输入多个数字，并且求总和与平均值   按回车 输入下一个数字*/

        Scanner scanner = new Scanner(System.in);

        /*和*/
        double sum = 0;
        /*平均值*/
        double avg = 0;
        /*统计个数*/
        int count = 0;
        System.out.println("请输入数据：");

        while (scanner.hasNextDouble()) {
            double v = scanner.nextDouble();
            System.out.println("你输入了第" + (count + 1) + "个数字，值是：" + v);
            sum = sum + v;
            count++;
        }

        System.out.println(count + "个数字之和为：" + sum);
        System.out.println(count + "个数字平均值为：" + sum / count);

        scanner.close();

    }
}
